package com.manolovn.trianglify.util;

import com.manolovn.trianglify.annotations.NonNull;
import com.manolovn.trianglify.domain.Edge;

/**
 * Edge distance comparator
 */
public class EdgeDistanceComparator implements Comparable<EdgeDistanceComparator> {
    /**
     * defines edge of the cell
     */
    public Edge edge;

    /**
     * defines distance of the cell
     */
    public double distance;

    /**
     * EdgeDistanceComparator parameterized constructor
     *
     * @param edge defines edge of the cell
     * @param distance defines distance of the cell
     */
    public EdgeDistanceComparator(Edge edge, double distance) {
        this.edge = edge;
        this.distance = distance;
    }

    @Override
    public int compareTo(@NonNull EdgeDistanceComparator o) {
        if (o.distance == distance) {
            return 0;
        } else if (o.distance < distance) {
            return 1;
        } else {
            return -1;
        }
    }
}
